<extend name="layout/edit" />

<block name="HEADER">

</block>

<block name="CONTENT">
	<control:grid id="grid"/>
	
	<script id="nameTemplet" type="text/html">
		<div style='line-height:24px;'>
			<p style='overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='{{row.name}}'>
				<a href="javascript:void(0);" class="link" on-click="page.edit()">{{row.name}}</a>
			</p>
			<p style='font-size: 13px;color:#e24444;'>
				￥{{row.sale_price}}
				<span style='text-decoration:line-through;color: #a7a7a7;margin-left:10px;'>
					{{row.price}}
				</span>	
			</p>	
		</div>    		
	</script>	
	
	
	<script id="statusTemplet" type="text/html">
		<div style='line-height:26px;font-size:10px;-webkit-transform:scale(0.9);'>
			{{if row.id }} 
				<span style='color:#e24444;padding:0 3px;' class="fl"> 新上 </span>
			{{/if}}
			{{if row.id }} 
				<span style='color:#e24444;padding:0 3px;' class="fl"> 置顶 </span>
			{{/if}}
			{{if row.id }} 
				<span style='color:#e24444;padding:0 3px;' class="fl"> 热销 </span> 
			{{/if}}
			{{if row.id }} 
				<span style='color:#e24444;padding:0 3px;' class="fl"> 精品 </span> 
			{{/if}}
		</div>
	</script>	
	
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns){
     		
     		//名称模板
		    ns.nameTemplet= function(e){
		    	return  template("nameTemplet",{row:e.data});
		    }
		    
		    //状态模板
		    ns.statusTemplet= function(e){
		    	return  template("statusTemplet",{row:e.data});
		    }
     	
		    //页面初始化
		    ns.init=function(){

		    }
		    
		    //新增
		    ns.add=function(){
		    	var filter = {
		            url: $.getModule('edit') ,
		            oid:"",
		            mode:1
		        }
		        $.openIframe(filter, "新增",['950px', '92%']);
		    }
		    
		    //编辑
		    ns.edit = function(id){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url: $.getModule('edit'),
		            oid: selectedRow.id ,
		            mode:3,
		           show_comment: id ? 1 : 0
		        }
		        $.openIframe(filter, "编辑",['950px', '92%']);
		    }  
		    
		    //设置显示
		    ns.setShow = function(id,type){
		    	grid.updateField(id,'is_show',type);
		    }
		    
		    //预览海报
		    ns.photos =function(urls){
		    	if(!urls){
		    		$.toast(0,'未上传凭证，或凭证已过期！');
		    		return;
		    	}
		    	layer.photos({
		    		anim:5,
				    photos: {
						data: $.map( String(urls).split(','), function(src) {
							return {
					    		"src": src
							}
						})
				    }
				});
		    }
		    
		    //商家信息
		    ns.seeShop = function(shop_id){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url:"modules/shop/list/edit",
		            oid: shop_id,
		            mode:3
		        }
		        $.openIframe(filter,"商家信息",['800px', '550px']);
		    }
		    
		    //商品评价
		    ns.evaluate = function(goods_id){
		    	var filter = {
		            url: "/modules/goods/goods/evaluate",
		            mode:1,
		            goods_id:goods_id
		        }
		        $.openIframe(filter,"商品评价",['800px', '520px']);
		    }
		    
		     //进货
		    ns.purchase = function(goods_id,goods_name){
		    	var filter = {
		            url: "/modules/goods/purchase/edit",
		            mode:1,
		            goods_id:goods_id,
		            goods_name:goods_name
		        }
		        $.openIframe(filter,"进货申请",['750px', '580px']);
		    }
		    
		    return ns;
		}({}));
		
		
		$(function(){ page.init();  });

	</script>
</block>